package com.clt.ess.base;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.clt.ess.CABeen.ApplySealCertResponse;
import com.clt.ess.gjzw.domain.FileData;
import com.clt.ess.gjzw.domain.FilePackage;
import com.clt.ess.gjzw.domain.SealCodeData;
import com.clt.ess.gjzw.domain.SignInfo;
import com.clt.ess.gjzw.domain.applySealCode.ApplySealCodeResponse;
import com.clt.ess.gjzw.domain.uploadRecordInfos.UploadRecordInfosCheckResultResponse;
import com.clt.ess.gjzw.utils.FastJsonUtils;
import com.clt.ess.gjzw.utils.GsonUtil;
import org.apache.http.util.EntityUtils;

import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static com.clt.ess.gjzw.utils.FastJsonUtils.json2ArrayList;
import static com.clt.ess.gjzw.utils.FastJsonUtils.json2List;
import static com.clt.ess.utils.Base64Utils.encodeBase64File;
import static com.clt.ess.utils.StringUtils.replaceJson;

public class test {
    public static void main(String[] args)  {
        String json = "{\"signInfo\":\"{\\\"signAlgorithm\\\":\\\"1.2.156.10197.1.501\\\",\\\"signValue\\\":\\\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZW7AUwd4n+spCc79dbOYfP84TXAjIQE1ekwZ9dLMw6QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArlFmR0TSOBO1XFYXNbOW4lQTJdNaemn5BAP+52dgLO8=\\\"}\",\"taskCode\":\"checkResult\",\"data\":\"[{\\\"errorCode\\\":\\\"0\\\",\\\"package\\\":{\\\"yzbm\\\":\\\"11000000001251\\\",\\\"appSymKeyEnc\\\":\\\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACOGJpNJEosBrkItxWNJ187vAa+sTvg6rq+qo6iuRI98AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAvG0WUlZhFqx3zOzycZxu7CEml/1yBwYue6hHhSaYOnHLo19wa8u2dRICzJQeSQ/iTN8dsfmY83Hch0V2C3RVEBAAAAAbVNpidDRdNDtfFumRO5Qa\\\",\\\"dataSymKeyEnc\\\":\\\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADigGosjNYRkq8R0LK14g6fc/duNcjVPK4cIv5ZsF9JnwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgOTRrl2XIbNznWh6xe+7vgMHty3i259bw6/+EKPBOJGQ0FMgWq8WHxj2FfkWZfNdysyqNAtgSc3ayxM0FaFDthAAAACTjn7NFMDOOs97Ud6cFVBr\\\",\\\"encFile\\\":\\\"qctnfs2BjZrHCQ5b+JknG9zt5EicBRt4qnlzMQmqmASLsXKRbuIJ6oYSCk4UHSCDwFstbngv1E/AuX0PweKhDjUwJG2RivrclexR8w5+YNI5YU8l3VzNcL1eEoCZk61IKK6hNSio6Zi8EnUSjx5WAF5WDTMfwgufBGY8pmmbyk2iGcBjubUlfpzEPi+gr7xVNYeYfzvSEDRJELQCMxU3/+sbzfzoGGebKX8GHTxnzCWM2hwG2dS+I4l8Q8Xwev7/112CaAAOPFX+Gxj50lFN9A3M3GL7GwhC5URD37/yhFw=\\\"}}]\",\"resultCode\":\"0\",\"resultCodeMsg\":\"查询成功＄1¤7\",\"version\":\"1.0\",\"taskTypeCode\":\"0\"}";

        JSONObject jsonObject = FastJsonUtils.jsonToJsonBean(json);
        Map map1 = jsonObject.toJavaObject(Map.class);

        String data = map1.get("data").toString();
        if (data!=null) {
            Pattern p = Pattern.compile("\\[|\\]");
            Matcher m = p.matcher(data);
            data = m.replaceAll("");
        }
        JSON json2 = FastJsonUtils.jsonToBean(data,JSON.class);
        Map map2 = json2.toJavaObject(Map.class);
        String aPackage = map2.get("package").toString();

        FilePackage filePackage = FastJsonUtils.jsonToBean(aPackage, FilePackage.class);
        System.out.println(filePackage);

    }
}
